package com.example.demo2.service.impl;

import com.example.demo2.dao.UserDao;
import com.example.demo2.model.User;
import com.example.demo2.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;


/**
 * @author alone
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public User saveUser(User user) {
        userDao.save(user);
        return user;
    }

    @Override
    public User getUserById(Integer userId) {
        Optional<User> user = userDao.findById(userId);
        return user.get();
    }

    @Override
    public List<User> getUserByIdNumberAndMobile(Object idNumber, Object mobile) {
        return userDao.getUserByIdNumberAndMobile(idNumber,mobile);
    }

}
